// customizer.cpp
// Customizer
// Protea Customizer / Main file with entry points
// Copyright (C) 2003, 2004, 2005 eXegeSys, Inc.
// Copyright (C) 2008 Bruce A. James
//
// This program is part of the Protea Project.
//
// The Protea Project is free software; you can redistribute it and/or modify it 
// under the terms of the GNU General Public License as published by the 
// Free Software Foundation, either version 3 of the License, or (at your 
// option) any later version.
//
// The Protea Project is distributed in the hope that it will be useful, but 
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
// for more details.
// 
// You should have received a copy of the GNU General Public License along 
// with this program.  If not, see <http://www.gnu.org/licenses/>.
//
// Please send correspondence to:
//
// theproteaproject@gmail.com
//

/////
//
// Customizer program
//
//	Handles all application customizations.  This includes adding,
//	changing and deleting fields, formats or screens.
//
//	After running the customizer program, a prep needs to be run in
//	order to move the new changes over.
//
/////
#include "customizer.h"

/////////////////////////////////////
//
// TRANSACTION DECLARATIONS
//
/////////////////////////////////////

// application.cpp
TRANSACTION( DelApplication );
TRANSACTION( RevApplications );
TRANSACTION( RevApplication );
TRANSACTION( ChgApplication );
TRANSACTION( DelFullApplication );

// components.cpp
TRANSACTION( ChgComponent );
TRANSACTION( RevComponents );

// database.cpp
TRANSACTION( RevDBRelate );
TRANSACTION( RevDatabases );
TRANSACTION( AddDatabase );
TRANSACTION( DelDatabase );

// fields.cpp
TRANSACTION( AddField );
TRANSACTION( DeleteField );
TRANSACTION( RevFields );
TRANSACTION( ChgField );
TRANSACTION( RevField );
TRANSACTION( CopyField );

// field_relate.cpp
TRANSACTION( AddFieldRelation );
TRANSACTION( DelFieldRelation );
TRANSACTION( RevFieldRelations );

// formats.cpp
TRANSACTION( AddFormat );
TRANSACTION( DeleteFormat );
TRANSACTION( ChgFormat );
TRANSACTION( CopyFormat );

// data_structures.cpp
TRANSACTION( AddDataStructure );
TRANSACTION( DelDataStructure );
TRANSACTION( ChgDataStructure );
TRANSACTION( FieldWhereUsed );

// messages.cpp
TRANSACTION( AddMessage );
TRANSACTION( ChgMessage );
TRANSACTION( DelMessage );
TRANSACTION( RevMessages );

// sysvals.cpp
TRANSACTION( ChangeSystemValue );
TRANSACTION( GetSysVals );

// transactions.cpp
TRANSACTION( ChangeTransaction );
TRANSACTION( ValidTransactionBuffer );

// info.cpp
TRANSACTION( RevDataTypes );
TRANSACTION( RevFormatTypes );

// literals.cpp
TRANSACTION( AddLiteral );
TRANSACTION( ChangeLiteral );
TRANSACTION( DeleteLiteral );
TRANSACTION( ReviewLiterals );
TRANSACTION( ReviewLiteral );

// litgroups.cpp
TRANSACTION( AddLiteralGroup );
TRANSACTION( ChangeLiteralGroup );
TRANSACTION( DeleteLiteralGroup );
TRANSACTION( ReviewLitGroups );
TRANSACTION( LitGroupWhereUsed );

// litrelate.cpp
TRANSACTION( AddLitToGroup );
TRANSACTION( DelLitFromGroup );
TRANSACTION( LiteralWhereUsed );

// litvalues.cpp
TRANSACTION( AddLiteralValue );
TRANSACTION( DelLiteralValue );
TRANSACTION( ChgLiteralValue );

// relate.cpp
TRANSACTION( AddDBRelation );
TRANSACTION( DeleteDBRelation );

// userexits.cpp
TRANSACTION( ChangeUserExit );
TRANSACTION( RevUserExit );
TRANSACTION( AssignUserExit );




extern "C" {

__EXPORT bool XCTransactionCode( XCTransRegServer* svr ) {
	// Check customizer licensing
	if ( true ) { // hard-code to "true" for now
		printf( "*******************************\n" );
		printf( "Loading customizer transactions\n" );
		printf( "*******************************\n" );

		// Applications
		svr->RegisterTransaction( TRANS_DELAPPLICATION, DelApplication );
		svr->RegisterTransaction( TRANS_REVAPPLICATION, RevApplication );
		svr->RegisterTransaction( TRANS_DELAPPLALL, DelFullApplication );
		svr->RegisterTransaction( TRANS_REVAPPLICATIONS, RevApplications );

		// Components
//		svr->RegisterTransaction( TRANS_ADDCOMPONENT, AddComponent );
		svr->RegisterTransaction( TRANS_CHGCOMPONENT, ChgComponent );
//		svr->RegisterTransaction( TRANS_DELCOMPONENT, DelComponent );
//		svr->RegisterTransaction( TRANS_REVCOMPONENT, RevComponent );
		svr->RegisterTransaction( TRANS_REVCOMPONENTS, RevComponents );

		// Fields
		svr->RegisterTransaction( TRANS_ADDFIELD, AddField );
		svr->RegisterTransaction( TRANS_CHGFIELD, ChgField );
		svr->RegisterTransaction( TRANS_DELETEFIELD, DeleteField );
		svr->RegisterTransaction( TRANS_REVFIELDS, RevFields );
		svr->RegisterTransaction( TRANS_GETFIELDNUMBER, RevField );
		svr->RegisterTransaction( TRANS_FIELDWHEREUSED, FieldWhereUsed );
		svr->RegisterTransaction( TRANS_COPYFIELD, CopyField );

		// Field Relates
		svr->RegisterTransaction( TRANS_ADDFLDRELATE, AddFieldRelation );
		svr->RegisterTransaction( TRANS_DELFLDRELATE, DelFieldRelation );
		svr->RegisterTransaction( TRANS_REVFLDRELATES, RevFieldRelations );

		// Formats
		svr->RegisterTransaction( TRANS_ADDFORMAT, AddFormat );
		svr->RegisterTransaction( TRANS_DELETEFORMAT, DeleteFormat );
		svr->RegisterTransaction( TRANS_CHGFORMAT, ChgFormat );
		svr->RegisterTransaction( TRANS_COPYFORMAT, CopyFormat );

		// Data structures
		svr->RegisterTransaction( TRANS_ADDDATASTRUCTURE, AddDataStructure );
		svr->RegisterTransaction( TRANS_DELDATASTRUCTURE, DelDataStructure );
		svr->RegisterTransaction( TRANS_CHGDATASTRUCTURE, ChgDataStructure );

		// Info
		svr->RegisterTransaction( TRANS_REVDATATYPES, RevDataTypes );
		svr->RegisterTransaction( TRANS_REVFORMATTYPES, RevFormatTypes );

		// Messages
		svr->RegisterTransaction( TRANS_ADDMESSAGE, AddMessage );
		svr->RegisterTransaction( TRANS_DELMESSAGE, DelMessage );
		svr->RegisterTransaction( TRANS_CHGMESSAGE, ChgMessage );
		svr->RegisterTransaction( TRANS_REVMESSAGES, RevMessages );

		// Sys Vals
		svr->RegisterTransaction( TRANS_CHGSYSVAL, ChangeSystemValue );
		svr->RegisterTransaction( TRANS_REVSYSVALS, GetSysVals );

		// Transactions
		svr->RegisterTransaction( TRANS_CHGTRANS, ChangeTransaction );
//		svr->RegisterTransaction( TRANS_VALIDTRANSBUFFER, ValidTransactionBuffer );

		// Literals
		svr->RegisterTransaction( TRANS_ADDLITERAL, AddLiteral );
		svr->RegisterTransaction( TRANS_CHGLITERAL, ChangeLiteral );
		svr->RegisterTransaction( TRANS_DELETELITERAL, DeleteLiteral );
		svr->RegisterTransaction( TRANS_REVIEWLITERALS, ReviewLiterals );
		svr->RegisterTransaction( TRANS_REVIEWLITERAL, ReviewLiteral );

		// Literal Groups
		svr->RegisterTransaction( TRANS_ADDLITGROUP, AddLiteralGroup );
		svr->RegisterTransaction( TRANS_DELETELITGROUP, DeleteLiteralGroup );
		svr->RegisterTransaction( TRANS_REVIEWLITGROUPS, ReviewLitGroups );
		svr->RegisterTransaction( TRANS_LITGROUPWHEREUSED, LitGroupWhereUsed );
		svr->RegisterTransaction( TRANS_CHGLITGROUP, ChangeLiteralGroup );

		// Literals/Groups
		svr->RegisterTransaction( TRANS_ADDLITTOGROUP, AddLitToGroup );
		svr->RegisterTransaction( TRANS_DELLITFROMGROUP, DelLitFromGroup );
		svr->RegisterTransaction( TRANS_LITWHEREUSED, LiteralWhereUsed );

		// Literal values
		svr->RegisterTransaction( TRANS_ADDLITVAL, AddLiteralValue );
		svr->RegisterTransaction( TRANS_DELLITVAL, DelLiteralValue );
		svr->RegisterTransaction( TRANS_CHGLITVAL, ChgLiteralValue );

		// DB Relations
		svr->RegisterTransaction( TRANS_ADDDBRELATION, AddDBRelation );
		svr->RegisterTransaction( TRANS_DELDBRELATION, DeleteDBRelation );
		svr->RegisterTransaction( TRANS_REVDBRELATE, RevDBRelate );
		svr->RegisterTransaction( TRANS_REVDATABASES, RevDatabases );
		svr->RegisterTransaction( TRANS_ADDDATABASE, AddDatabase );
		svr->RegisterTransaction( TRANS_DELDATABASE, DelDatabase );

		// User Exits
		svr->RegisterTransaction( TRANS_CHGUE, ChangeUserExit );
		svr->RegisterTransaction( TRANS_ASSIGN_UE, AssignUserExit );
		svr->RegisterTransaction( TRANS_REVUSEREXIT, RevUserExit );
	} else
		printf( "Not licensed for customizer technology\n" );

	return true;
};

};
